package com.tourlaid.mamagerment.action.wx

import com.tourlaid.mamagerment.ao.wx.ThoughtDetailAo
import com.tourlaid.mamagerment.entity.ResponseData
import org.springframework.web.bind.annotation.RequestMapping
import org.springframework.web.bind.annotation.RestController
import javax.annotation.Resource

/**
 * Created by xiaoyongge on 2017/7/23.
 * 首页
 */
@RestController
@RequestMapping("/tld/admin/tdetail")
class ThoughtDetailAction {

    @Resource
    var thoughtDetailAo: ThoughtDetailAo? = null

    @RequestMapping("/getUserInfo.json")
    fun getUserInfo(detailUserId: Long): ResponseData<MutableMap<String, Any?>> {
        val userInfo = thoughtDetailAo!!.getUserInfo(detailUserId)
        return ResponseData(userInfo)
    }

    @RequestMapping("/getThought.json")
    fun getThought(thoughtId: Long): ResponseData<MutableMap<String, Any?>> {
        val map = thoughtDetailAo!!.getThought(thoughtId)
        return ResponseData(map)
    }

    /**
     * 取最新的前50条评论
     */
    @RequestMapping("/queryCommentsAll.json")
    fun queryCommentsAll(toUserId: Long, thoughtId: Long): ResponseData<MutableList<MutableMap<String, String?>>> {
        val list = thoughtDetailAo!!.queryCommentsAll(toUserId, thoughtId)
        return ResponseData(list)
    }

    /**
     * 我和发布者之间的评论
     */
    @RequestMapping("/queryWeComments.json")
    fun queryWeComments(toUserId: Long, thoughtId: Long): ResponseData<MutableList<MutableMap<String, Any?>>> {
        val list = thoughtDetailAo!!.queryWeComments(toUserId, thoughtId)
        return ResponseData(list)
    }

    /**
     * 发布评论
     */
    @RequestMapping("/publicComment.json")
    fun publicComment(toUserId: Long?, thoughtId: Long?, content: String?): ResponseData<String> {
        thoughtDetailAo!!.publicComment(toUserId, thoughtId, content)
        return ResponseData<String>()
    }

    /**
     * 删除评论
     */
    @RequestMapping("/deleteComment.json")
    fun deleteComment(thoughtId: Long, commentId: Long): ResponseData<String> {
        thoughtDetailAo!!.deleteComment(thoughtId, commentId)
        return ResponseData<String>()
    }

    /**
     * 打赏
     */
    @RequestMapping("/reward.json")
    fun reward(thoughtId: Long): ResponseData<String> {
        thoughtDetailAo!!.reward(thoughtId)
        return ResponseData<String>()
    }

    /**
     * 已有打赏
     */
    @RequestMapping("/getReward.json")
    fun getReward(thoughtId: Long): ResponseData<Int> {
        val reward = thoughtDetailAo!!.getReward(thoughtId)
        return ResponseData(reward)
    }
}